home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Report Writers / Crystal Repot 9.0 Full CD version / Setup.exe / ProgramF / CommonFi / CRYSTAL / 20 / VIEWERS / CRSM8459.ASP next >
Encoding:
Text File  |  2002-05-10  |  3.0 KB  |  95 lines

  1. <% Option Explicit 
  2. Response.ExpiresAbsolute = Now() - 1
  3. Session.CodePage  = 65001 ' UTF-8
  4. Const ACTION_VIEWREPORT = "viewReport"
  5. Const ACTION_REFRESH = "refresh"
  6. Const SMARTTAGACTIONATTR = "smarttagaction"
  7.  
  8. Function OutputReport()
  9.     Dim smarttagAction, reportSource
  10.     Dim dataContext, objectName
  11.     Dim viewer
  12.     Dim smartTagInfoParser
  13.  
  14.     Dim requestMethod
  15.     requestMethod = UCase(Request.ServerVariables("REQUEST_METHOD"))
  16.  
  17.     Select Case requestMethod
  18.         Case "POST"
  19.             smarttagAction = Request.Form(SMARTTAGACTIONATTR)
  20.         Case "GET"
  21.             smarttagAction = Request.QueryString(SMARTTAGACTIONATTR)
  22.         Case Else
  23.             smarttagAction = Empty
  24.     End Select
  25.  
  26.     ' Initialize the Smart Tag info parser
  27.     Set smartTagInfoParser = CreateObject("CrystalReports.CrystalReportSmartTagInfoParser")
  28.     call smartTagInfoParser.Init(request)
  29.  
  30.     reportSource = smartTagInfoParser.ReportSource
  31.     
  32.     If (smarttagAction = ACTION_REFRESH) Then
  33.         ' Refresh
  34.         If (Not IsEmpty(reportSource)) Then
  35.             Set viewer = CreateObject("CrystalReports.CrystalReportPartsViewer")
  36.             With viewer
  37.                 .ReportParts = smartTagInfoParser.ReportParts
  38.                 .RecordNumber = 1
  39.                 .IsOwnPage = true
  40.                 .IsDisplayTitle = false
  41.                 .IsDisplayHeadings = false
  42.                 .DatabaseLogOnInfos = smartTagInfoParser.ConnectionInfos
  43.                 .ParameterFields = smartTagInfoParser.ParameterFields
  44. '                .EnterpriseLogon = smartTagInfoParser.EnterpriseLogon
  45.                 .ReportSource = reportSource
  46.                 .Name = "SmartTagViewer"
  47.             End With
  48.  
  49.             Call viewer.Refresh()
  50.         End If
  51.     Else
  52.         ' View report
  53.         If (IsEmpty(reportSource) OR (Len(reportSource) = 0)) Then
  54.         ' This is not from the SmartTag.  Use the HTML page viewer to view the report
  55.             reportSource = Session("CrystalReportSmartTagReportSource")
  56.         End If
  57.  
  58.         If (IsEmpty(reportSource)) Then
  59.             Call Err. Raise (vbObjectError + 1, "Crystal Report Smart Tag Viewer", "Report source is not defined")
  60.         Else
  61.             dataContext = smartTagInfoParser.DataContext 
  62.             objectName = smartTagInfoParser.ObjectName 
  63.  
  64.             Session("CrystalReportSmartTagReportSource") = reportSource
  65.  
  66.             Set viewer = CreateObject("CrystalReports.CrystalReportViewer")
  67.             
  68.             With viewer
  69.                 .ReportSource = reportSource
  70.                 .IsOwnPage = true
  71.                 .Name = "HTML Page Viewer"
  72.             End With
  73.  
  74.             If (Not (IsEmpty(objectName) OR (Len(objectName) = 0))) Then
  75.                 Call viewer.NavigateTo(dataContext, objectName)
  76.             End If
  77.         End If
  78.  
  79.     End If
  80.     
  81.     Call viewer.ProcessHttpRequest(Request, Response, Session)
  82.     
  83.     if Err.number <> 0 then
  84.         Response.Write Err.Description
  85.         Err.Clear
  86.     end if
  87.  
  88.     Set smartTagInfoParser = nothing
  89.     Set viewer = nothing
  90. End Function
  91.  
  92. %>
  93.  
  94. <% OutputReport%>
  95.